<%@ page language="java" pageEncoding="UTF-8"%>
<%@include file="/global/global-head.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>吉车惠后台管理系统</title>
    <%@include file="/global/global-other.jsp" %>

    <script type="text/javascript">
        var $bn_advertiser_list = new Object();
        var $bn_advertiser_list_Datagrid;
        var $menu;
        var $bn_advertiser_list_toolbar = [{
                text:'<i class="fa fa-search" aria-hidden="true"></i>刷新',
                handler:function(){
                    $bn_advertiser_list.reload();
                }
            },{
                text:'<i class="fa fa-plus-square" aria-hidden="true"></i>添加',
                handler:function(){
                    $bn_advertiser_list.saveInit();
                }
            },
            {
                text:'<i class="fa fa-edit" aria-hidden="true"></i>编辑',
                handler:function(){
                    $bn_advertiser_list.updateInit();
                }
            },
            {
                text:'<i class="fa fa-trash-o" aria-hidden="true"></i>删除',
                handler:function(){
                    $bn_advertiser_list.delete();
                }
            }
        ];
        $(function(){
            //gird 初始化
            $bn_advertiser_list_Datagrid = $('#bn_advertiser_list_Datagrid').datagrid({
                filterBtnIconCls:'icon-filter',
                queryParams: {
                    filter_EQ_delete_status : 0
                },
                pageSize : 20,
                remoteFilter:true
            });

            $bn_advertiser_list_Datagrid.datagrid('enableFilter', [
                {field:'email',type:'label'},
                {field:'qq',type:'label'},
                {field:'address',type:'label'},
                {field:'createAt',type:'label'},
                {field:'t',type:'label'}
            ]);

        });

        //刷新

        $bn_advertiser_list.reload = function(){
            $bn_advertiser_list_Datagrid.datagrid('reload');
        };

        var viewDialog ;
        //添加
        $bn_advertiser_list.saveInit = function(){
            viewDialog = parent.$.dialog({
                title: '<i class="fa fa-th-large"></i><span class="dialog-title">&nbsp;广告主添加<span>',
                href: '${ctx}/bn/advertiser/insert?_m=init&r='+Math.random(),
                width: 800,
                height: 440,
                modal: true,
                onClose : function() {
                    $(this).dialog('destroy');
                },
                buttons: [{
                    text:'<i class="fa fa-floppy-o" aria-hidden="true"></i>&nbsp;保 存',
                    width:'70px',
                    handler: function(){
                        viewDialog.find('iframe').get(0).contentWindow.submitForm(viewDialog, $bn_advertiser_list_Datagrid);
                    }
                },{
                    text:'<i class="fa fa-reply" aria-hidden="true"></i>&nbsp;返 回',
                    width:'70px',
                    handler: function(){
                        viewDialog.dialog('destroy');
                    }
                }]
            });
        }

        //编辑
        $bn_advertiser_list.updateInit = function (){
            var row = $bn_advertiser_list_Datagrid.datagrid('getSelected');
            if(row==null){
                parent.$.messager.alert("提示",errMsg("请选择一行数据！"),"error");
            }else{
                viewDialog = parent.$.dialog({
                    title: '<i class="fa fa-th-large"></i><span class="dialog-title">&nbsp;广告主编辑<span>',
                    href: '${ctx}/bn/advertiser/update?_m=init&id='+row.advertiserId+'&r='+Math.random(),
                    width: 800,
                    height: 440,
                    modal: true,
                    onClose : function() {
                        $(this).dialog('destroy');
                    },
                    buttons:[{
                        text:'<i class="fa fa-floppy-o" aria-hidden="true"></i>保存',
                        width:'70px',
                        handler:function(){
                            viewDialog.find('iframe').get(0).contentWindow.submitForm(viewDialog, $bn_advertiser_list_Datagrid);
                        }
                    },{
                        text:'<i class="fa fa-reply" aria-hidden="true"></i>返回',
                        width:'70px',
                        handler:function(){
                            viewDialog.dialog('destroy');
                        }
                    }]
                });
            }
        }

        //删除
        $bn_advertiser_list.delete = function (){
            var row = $bn_advertiser_list_Datagrid.datagrid('getSelected');
            if(row==null){
                parent.$.messager.alert("提示",errMsg("请选择一行数据！"),"error");
            }else{
                parent.$.messager.confirm('提示','是否要删除广告主名称【'+row.advertiserName+'】？',function(flag){
                    if (flag){
                        $.post('${ctx}/bn/advertiser/delete?_m=exec', {id : row.advertiserId}, function(json) {
                            if(statusMsg(json)){
                                parent.$.messager.alert("提示","删除成功！","info",function(){
                                    $bn_advertiser_list_Datagrid.datagrid('reload');
                                });
                            }
                        }, "JSON");
                    }
                });
            }
        }

    </script>
</head>
<body>
<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'center',border:false">
        <table id="bn_advertiser_list_Datagrid"  style="width:100%;height:100%"
               data-options="border:false,rownumbers:true,autoRowHeight:false,singleSelect:true,pagination:true,sortName:'createAt',sortOrder:'desc',toolbar:$bn_advertiser_list_toolbar,rowStyler: function(index,row){return {style:'height:30px'};},url:'${ctx}/bn/advertiser/search?_m=load',method:'post'">
            <thead>
            <tr>
                <th data-options="field:'advertiserNo',width:120,align:'center'">广告主编号</th>
                <th data-options="field:'advertiserName',width:120,align:'center'">广告主名称</th>
                <th data-options="field:'phone',width:100,align:'center'">联系电话</th>
                <th data-options="field:'email',width:150,align:'center'">邮箱</th>
                <th data-options="field:'qq',width:100,align:'center'">QQ</th>
                <th data-options="field:'address',width:200,align:'center'">地址</th>
                <th data-options="field:'createAt',width:150,align:'center'">添加时间</th>
                <th data-options="field:'t',width:20,align:'center'"></th>
            </tr>
            </thead>
        </table>
    </div>
</div>
</body>
</html>